/**
  ******************************************************************************
  * @file           : SEC_LEAD.cpp
  * @author         : sally
  * @brief          : None
  * @attention      : None
  * @date           : 24-11-11
  ******************************************************************************
  */


#include "SEC_LEAD.h"

namespace droneswarm
{
    SEC_LEAD::SEC_LEAD(const std::string& ip, const uint16_t& port)
        : m_ip(ip),
          m_port(port),
          m_udp_service(new UdpService(m_ip, m_port,THREAD_NUMS))
    {

    }

    void SEC_LEAD::sendHelloMessage(const std::string& message)
    {

        uint8_t i;
        for(i = 0;i<MAX_REPETITIONS;++i)
        {
            if(m_udp_service->send_message(BROADCAST_IP_ADDRESS,UDP_SERVICE_PORT,message))
            {
                break;
            }
        }

        if(i >=MAX_REPETITIONS)
        {
            std::cerr << "Failed to send message after " << MAX_REPETITIONS << " attempts. Exiting program." << std::endl;
        }

    }

    void SEC_LEAD::handleHelloMessage()
    {

    }

    std::string SEC_LEAD::generateHelloMessage()
    {
        NodeMessage node_message;
        node_message.set_message_type(HELLO);
        node_message.set_node_id("199805130711");
        
    }
} // droneswarm
